import Vue from 'vue'
import App from './App.vue'
import router from './router'
import  qs from 'qs'
Vue.prototype.$qs = qs

Vue.config.productionTip = false

import axios from 'axios'
Vue.prototype.$axios = axios

//引入element-ui
import '@/plugins/elementui.js'
//引入全局css
import '@/assets/css/global.css';

//导入基础的url地址
import baseurl from '@/plugins/baseurl.js'
Vue.prototype.$baseurl = baseurl



// Add a request interceptor
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  config["headers"]={'jwttoken': sessionStorage.getItem("jwttoken")}
  return config;
}, function (error) {
  // Do something with request error
  return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
  // Do something with response data
  if(response.data.code==100101){
    alert('请登录')
    location.href='http://localhost:8080/login'
  }
  console.log('response',response)
  return response;
}, function (error) {
  // Do something with response error
  return Promise.reject(error);
});


new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
